using HCI.Questionaire.Exceptions;

namespace HCI.Questionaire.Entities
{
    public class OneAnswerQuestion : Question
    {

        public override void ValidateAnswer()
        {
            int count = 0;
            foreach (var item in this.AnswerCollection)
            {
                if (item.IsAnswered)
                    count++;
            }

            if (count > 1)
                throw new AnswerInvalidException("Answer cannot more than one.");

            if (count < 1)
                throw new RequiredAnswerException("Required at less on answer.");
        }
    }
}
